/**************************************************************************************
*  Component of benchmarking program.
**************************************************************************************
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL RTJ COMPUTING BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************************/
public class LogicBenchmarkUnit extends BenchmarkUnit {

    private int wIterationCount;

    public LogicBenchmarkUnit() {
        name = "Logic";
        wIterationCount = 100;
    }

    public int execute() {

        boolean flag1 = true;
        boolean flag2 = true;
        boolean flag3 = true;
        boolean flag4 = true;
        boolean flag5 = true;
        boolean flag6 = true;
        boolean flag7 = true;
        boolean flag8 = true;
        boolean flag9 = true;
        boolean flag10 = true;
        boolean flag11 = true;
        boolean flag12 = true;
        boolean flag13 = true;

        flag8 = true;
        flag9 = true;
        flag10 = true;
        flag11 = true;
        flag12 = true;
        flag13 = true;

        for (int i = 0; i < wIterationCount; i++) {

            if ((flag1 || flag2) && (flag3 || flag4) && (flag5 || flag6 || flag7)) {
                flag8 = !flag8;
                flag9 = !flag9;
                flag10 = !flag10;
                flag11 = !flag11;
                flag12 = !flag12;
                flag13 = !flag13;
                flag1 = !flag1;
                flag2 = !flag2;
                flag3 = !flag3;
                flag4 = !flag4;
                flag5 = !flag5;
                flag6 = !flag6;
                flag1 = !flag1;
                flag2 = !flag2;
                flag3 = !flag3;
                flag4 = !flag4;
                flag5 = !flag5;
                flag6 = !flag6;
            }
        }
        flag1 = true;
        flag2 = false;
        flag3 = true;
        flag4 = false;
        flag5 = true;
        flag6 = false;

        for (int j = 0; j < wIterationCount; j++) {
            if ((flag1 || flag2) && (flag3 || flag4) && (flag5 || flag6 || flag7)) {
                flag1 = !flag1;
                flag2 = !flag2;
                flag3 = !flag3;
                flag4 = !flag4;
                flag5 = !flag5;
                flag6 = !flag6;
                flag8 = !flag8;
                flag9 = !flag9;
                flag10 = !flag10;
                flag11 = !flag11;
                flag12 = !flag12;
                flag13 = !flag13;
                flag8 = !flag8;
                flag9 = !flag9;
                flag10 = !flag10;
                flag11 = !flag11;
                flag12 = !flag12;
                flag13 = !flag13;
            }
        }

        if (flag1 || flag3)
            return 1;
        else if (flag8)
            return ( !(flag1 || flag3) ? 1 : 0);

        return 1;
    }

}

